package com.webserver.controller;

import com.google.zxing.qrcode.encoder.QRCode;
import com.webserver.annotation.Controller;
import com.webserver.annotation.RequestMapping;
import com.webserver.http.HttpServletRequest;
import com.webserver.http.HttpServletResponse;
import qrcode.QRCodeUtil;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

@Controller
public class ToolsController {
    @RequestMapping("/myweb/createQR")
    public void  creatQR(HttpServletRequest request, HttpServletResponse response){
        System.out.println("正在生成二维码.....");
        String content = request.getParameter("content");
        System.out.println("内容："+content);

        try{
            QRCodeUtil.encode(content,response.getOutputStream());
            response.setContentType("image/jpeg");
        }catch (Exception e){
            e.printStackTrace();
        }

        System.out.println("二维码生成完毕！！");
    }

}
